﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using PBOffice.BLL;
using PBOffice.DAL;

public partial class FilesPage_AddFolder : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        ((ScriptManager)Master.Master.FindControl("ScriptManager1")).RegisterPostBackControl(ImageButtonSave);
        FilesPage_FileIndex.SonPage = "AddFolder";//指明子页面
        if (Session["userManage"] != null)
        {
            User user = (User)Session["userManage"];
            LabelCreateUser.Text = user.UserId.ToString();
        }
        else
        {
            Response.Redirect("~/login.aspx");
        }
    }
    protected void ImageButtonSave_Click(object sender, ImageClickEventArgs e)
    {
        Document doc = new Document();
        doc.DocId = TextBoxFolderName.Text.Trim();//名称
        doc.DocMemo = TextBoxMemo.Text;//备注
        doc.DocPath = LabelAddress.Text + "\\" + TextBoxFolderName.Text.Trim();//路径
        User userNo = (User)Session["userManage"];
        doc.FatherNode = Convert.ToInt32(LabelDocId.Text);
        if (FileOperationBLL.AddFolder(doc,userNo.UserNo))
        {
            Response.Write("<script>alert('创建成功');window.location.href='ShowFiles.aspx'</script>");
        }
        else
        {
            Response.Write("<script>alert('创建失败。是否存在同名文件？');window.location.href='AddFolder.aspx'</script>");
        }
    }
}